﻿/*
 * Copyright (c) 2015-2016 Constantijn Evenhuis (blueprints@const.nl)
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
using System;

namespace Blueprints.Resolution
{
    /// <summary>
    /// Resolves types and provides information about them.
    /// </summary>
    public interface ITypeResolver
    {
        /// <summary>
        /// Gets the type category for <paramref name="type"/>.
        /// </summary>
        /// <param name="type">The type to inspect.</param>
        /// <returns>The type category for <paramref name="type"/>.</returns>
        TypeCategory GetTypeCategory(Type type);
        
        /// <summary>
        /// Gets the value descriptor for <paramref name="type"/>.
        /// </summary>
        /// <param name="type">The type to get the descriptor for.</param>
        /// <returns>The value descriptor for <paramref name="type"/>.</returns>
        IValueDescriptor GetValueDescriptor(Type type);

        /// <summary>
        /// Gets the object descriptor for <paramref name="type"/>.
        /// </summary>
        /// <param name="type">The type to get the descriptor for.</param>
        /// <returns>The object descriptor for <paramref name="type"/>.</returns>
        IObjectDescriptor GetObjectDescriptor(Type type);

        /// <summary>
        /// Gets the array descriptor for <paramref name="type"/>.
        /// </summary>
        /// <param name="type">The type to get the descriptor for.</param>
        /// <returns>The array descriptor for <paramref name="type"/>.</returns>
        IArrayDescriptor GetArrayDescriptor(Type type);

        /// <summary>
        /// Gets the collection descriptor for <paramref name="type"/>.
        /// </summary>
        /// <param name="type">The type to get the descriptor for.</param>
        /// <returns>The collection descriptor for <paramref name="type"/>.</returns>
        ICollectionDescriptor GetCollectionDescriptor(Type type);
        
        /// <summary>
        /// Attempts to resolve a type.
        /// </summary>
        /// <param name="name">The name of the type.</param>
        /// <param name="type">The resolved type.</param>
        /// <returns>True if the type was successfully resolved, false otherwise.</returns>
        bool TryGetType(string name, out Type type);
        
        /// <summary>
        /// Gets the name of the type.
        /// </summary>
        /// <param name="type">The type to get the name of.</param>
        /// <returns>The name of the type.</returns>
        string GetTypeName(Type type);
    }
}